package com.lucky.back.controller;

import com.lucky.back.pojo.dto.AddressAddNewDTO;
import com.lucky.back.pojo.vo.AddressStandarVO;
import com.lucky.back.service.IAddressService;
import com.lucky.back.web.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@Api(tags = "12.添加地址模块")
@RequestMapping("/address")
public class AddressController
{

    @Autowired
    IAddressService service;

    @PostMapping("/add")
    public JsonResult<Void> add(AddressAddNewDTO addressAddNewDTO){
        service.addNew(addressAddNewDTO);
        return JsonResult.ok();
    }

    @GetMapping("/{id}")
    public JsonResult<AddressStandarVO> getById(@PathVariable Long id){
        AddressStandarVO addressStandarVO=new AddressStandarVO();
        addressStandarVO=service.getStandardById(id);
        return JsonResult.ok(addressStandarVO);
    }
}
